#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
int T;
int n,m;
double L,V;
double d[N],v0[N],a[N];
double p[N],l[N],r[N];
int ans1,ans2;
struct node{
    int LF,RI;
};
vector<node> v;
void solve(int x){
    if(p[m]<l[x] ||r[x]<p[1]) return ;
    if(p[m]==l[x] && a[x]>0) return ;
    if(p[1]==r[x] && a[x]<0) return ;
    int Lf,Ri;
    int lf=1,ri=m;
    while(lf<ri){
        int mid=(lf+ri+1)>>1;
        if(p[mid]<l[x] || (a[x]>0 && p[mid]==l[x])){
            lf=mid;
        }
        else{
            ri=mid-1;
        }
    }
    Lf=lf+1;
    if(p[1]>l[x]) Lf=1;
  //  if(Lf==m+1) cout<<"666\n\n";
    lf=1,ri=m;
    while(lf<ri){
        int mid=(lf+ri)>>1;
        if(p[mid]>r[x] || (a[x]<0  && p[mid]==r[x])){
            ri=mid;
        }
        else{
            lf=mid+1;
        }
    }
    Ri=ri;
    if(p[m]<r[x]) Ri=m+1;
  //  else cout<<"666\n\n";
//    cout<<x<<":"<<Lf<<" "<<Ri<<"\n";
    if(Lf>=Ri) return ;
    v.push_back((node){Lf,Ri});
    ans1++;
//    for(int i=Lf;i<=Ri;i++)
//        mp[i]=1;
}
bool cmp(node x,node y){
    return x.LF<y.LF;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>T;
    while(T--){
        v.clear();
        ans1=ans2=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v0[i]>>a[i];
            if(a[i]!=0){
                double s=(V*V-v0[i]*v0[i])/(2.0*a[i]);
                if(a[i]>0){
                    l[i]=max(d[i]+s,d[i]);
                    r[i]=L+1.0;
                }
                else{
                    l[i]=d[i];
                    r[i]=max(d[i]+s,d[i]);
                }
            }
            else{
                if(v0[i]<=V)  l[i]=r[i]=-1;
                else {
                    l[i]=d[i];
                    r[i]=L+1.0;
                }
            }
        }
//        for(int i=1;i<=n;i++){
//            cout<<l[i]<<" "<<r[i]<<"\n";
//        }
//        cout<<"\n";
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
        for(int i=1;i<=n;i++){
            solve(i);
        }


        sort(v.begin(),v.end(),cmp);
        int R=1;
        for(int i=0;i<v.size();i++){
          //  cout<<v[i].LF<<" "<<v[i].RI<<"\n";
            if(v[i].LF>=R){
                ans2++;
                R=v[i].RI;
            }
            R=min(R,v[i].RI);
        }
        cout<<ans1<<" "<<m-ans2<<"\n";
    }
    return 0;
}
